<template>
  <view class="uni-calendar-item__weeks-box"
        :class="{
		'uni-calendar-item--disable':weeks.disable,
		'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
		'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
		'uni-calendar-item--multiple': weeks.multiple
		}"
        @click="choiceDate(weeks)">
    <view :class="{
			'uni-calendar-item__weeks-box-item':true,
			'uni-calendar-item__weeks-box-item_active':selected&&weeks.extraInfo,
			'uni-calendar-item__weeks-box-item_noactive':Number(weeks.date) < Number(new Date().getDate()) && !weeks.extraInfo
		}">
      <!-- {{selected}} -->
      <!-- {{weeks.extraInfo}} -->
      <text class="uni-calendar-item__weeks-box-text"
            :class="{
				'uni-calendar-item--isDay-text': weeks.isDay,
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'uni-calendar-item--multiple': weeks.multiple,
				'uni-calendar-item--disable':weeks.disable,
				'addcolor': (selected&&weeks.extraInfo) || (Number(weeks.date) < Number(new Date().getDate()) && !weeks.extraInfo)
				}">{{weeks.date}}</text>
      <!-- <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
				'uni-calendar-item--isDay-text':weeks.isDay,
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'uni-calendar-item--multiple': weeks.multiple,
				}">今天</text> -->
      <text v-if="lunar&&!weeks.extraInfo"
            class="uni-calendar-item__weeks-lunar-text"
            :class="{
				'uni-calendar-item--isDay-text':weeks.isDay,
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'uni-calendar-item--multiple': weeks.multiple,
				'uni-calendar-item--disable':weeks.disable,
				}">{{weeks.isDay?'今天': (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
      <text v-if="weeks.extraInfo&&weeks.extraInfo.info&&selected"
            class="uni-calendar-item__weeks-lunar-text"
            :class="{
				'uni-calendar-item--extra':weeks.extraInfo.info,
				'uni-calendar-item--isDay-text':weeks.isDay,
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'uni-calendar-item--multiple': weeks.multiple,
				'uni-calendar-item--disable':weeks.disable,
				}"></text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    weeks: {
      type: Object,
      default() {
        return {}
      }
    },
    calendar: {
      type: Object,
      default: () => {
        return {}
      }
    },
    selected: {
      type: Array,
      default: () => {
        return []
      }
    },
    lunar: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    choiceDate(weeks) {
      this.$emit('change', weeks)
    }
  }
}
</script>

<style lang="scss" scoped>
.uni-calendar-item__weeks-box {
  flex: 1;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  // width: 80rpx;
  height: 80rpx;
}

.uni-calendar-item__weeks-box-text {
  font-size: $uni-font-size-base;
  color: $uni-text-color;
}

.uni-calendar-item__weeks-lunar-text {
  font-size: $uni-font-size-sm;
  color: $uni-text-color;
}

.uni-calendar-item__weeks-box-item {
  position: relative;
  /* #ifndef APP-NVUE */
  display: flex;
  /* #endif */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}
.uni-calendar-item__weeks-box-item_active {
  background-image: url(../../static/image/yhqd_ico_jl_sel@2x.png);
  background-repeat: no-repeat;
  background-size: 50% 50%;
  background-position: 50% 50%;
}
.uni-calendar-item__weeks-box-item_noactive {
  background-image: url(../../static/image/yhqd_ico_jl_nor@2x.png);
  background-repeat: no-repeat;
  background-size: 50% 50%;
  background-position: 50% 50%;
}
.addcolor {
  color: #ffffff !important;
}
.uni-calendar-item__weeks-box-circle {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 8px;
  background-color: $uni-color-error;
}

.uni-calendar-item--disable {
  background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  color: $uni-text-color-disable;
  opacity: 0; //直接属性设置让不是本月的日期隐藏
}

.uni-calendar-item--isDay-text {
  color: #333;
  // background-color: #A4A9C7;
}

.uni-calendar-item--extra {
  color: $uni-color-error;
  opacity: 0.8;
}

.uni-calendar-item--checked {
  // color: #fff;
  color: black;
  // color: #A4A9C7;
  opacity: 0.8;
}

.uni-calendar-item--multiple {
  background-color: $uni-color-primary;
  // background-color: #A4A9C7;
  color: #fff;
  opacity: 0.8;
}
</style>
